<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 回顾
    // Promise 
    function fn(){
        return new Promise((resolve,reject)=>{
           setTimeout(() => {
             resolve(10)
           },2000);
        })
    }
    function fun(){
        return new Promise((resolve,reject)=>{
           setTimeout(() => {
             resolve(30)
           },3000);
        })
    }
    // console.log(fn());
    // fn().then(res=>{
    //     console.log(res);
    // })

    // async   await 他是es7 把异步变为同步的方法
    // 一个async可以对应多个await
    // async await是成对出现


    async function fn1(){
        // fn()是异步
      let num1 = await fn()
      let num2 = await fun()

    //   console.log(num1);
    //   console.log(num2);
        // console.log(888);
     
        return  num1
    }
   console.log(fn1());
    fn1().then(res=>{
        console.log(res);
   })






</script>
</html>